package com.toune.gdlocation.location

import android.graphics.Color
import com.amap.api.services.core.PoiItem
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.toune.gdlocation.R

class PoiAdapter(layoutResId: Int, data: MutableList<PoiItem>?) : BaseQuickAdapter<PoiItem, BaseViewHolder>(layoutResId, data) {
    override fun convert(helper: BaseViewHolder?, item: PoiItem?) {
        helper!!.setText(R.id.nameTv, item!!.title)
        helper.setTextColor(R.id.nameTv, if(pos == helper.layoutPosition) Color.GREEN else Color.parseColor("#333333"))
//        helper.setText(R.id.subTv, "${Arith.getValue(item.distance*0.001,2)}km | ${item.snippet}")
        helper.setText(R.id.subTv, "${item.snippet}")
        helper.setGone(R.id.selectTv, pos == helper.layoutPosition)
    }

    var pos = -1
    fun setSelectPos(position: Int) {
        pos = position
        notifyDataSetChanged()
    }

}
